package com.bestcem.xm.deliver.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum DeliverSurveyDataSurveyStatusEnum {

    DELIVERSURVEYDATA_SURVEY_STATUS_UNSUBMIT(0, "未提交"),

    DELIVERSURVEYDATA_SURVEY_STATUS_SUBMIT(1, "提交"),

    DELIVERSURVEYDATA_SURVEY_STATUS_UNANSWER(2, "未回答");

    @EnumValue
    private final int value;

    private final String desc;

    public static String getDescByValue(int value) {
        List<DeliverSurveyDataSurveyStatusEnum> collect = Arrays.stream(DeliverSurveyDataSurveyStatusEnum.values()).filter(one -> one.getValue() == value)
                .collect(Collectors.toList());
        if (CollectionUtils.isEmpty(collect)) {
            return "";
        } else {
            return Objects.requireNonNull(collect.stream().findFirst().orElse(null)).getDesc();
        }
    }
}
